package com.chixing.day18_thread;

public class Consumer implements Runnable{
    private PublicResource publicResource;

    public Consumer(PublicResource publicResource){
        this.publicResource = publicResource;
    }
    @Override
    public void run() {

        while (true) {
            for (int i = 0; i < 20; i++) {
                publicResource.consume();
                try {
                    Thread.sleep(15);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
